Skip to main content
Feedback

Assign Attributes Policy

The assign-attributes policy sets variables such as request attributes, message attributes and other execution context attributes.

You can use it to retrieve initial request attributes after Transform headers or Transform query parameters policies and reuse them in other policies (Dynamic routing, for example).

Timing

On RequestOn ResponseOn Request ContentOn Response Content
XXXX

Configuration

PropertyRequiredDescriptionTypeDefault
scopenoThe execution scope (REQUEST, RESPONSE, REQUEST_CONTENT, RESPONSE_CONTENT).stringREQUEST
attributesyesList of attributes. See below.

Attributes

PropertyRequiredDescriptionTypeDefault
nameyesAttribute name.string
valueyesAttribute value (can be EL)string

Examples

Request header Inject request attributes into the context attributes:

"assign-attributes": {
"attributes": [
{
"name": "initialContentTypeHeader,
"value": "{#request.headers['Content-Type']}"
},
{
"name": "initialFooParamHeader,
"value": "{#request.params['foo']}"
}
]
}

To extract the request attributes you can use the following syntax:

Get the content-type header:

{#context.attributes['initialRequest'].headers['content-type']}

Get the foo query param:

{#context.attributes['initialRequest'].params['foo']}

Errors

HTTP status code

CodeMessage
500An error occurred while setting request attributes in the execution context.
On this Page